/*
 * events_sender.cpp
 *
 *  Created on: 04.05.2011
 *      Author: inkooboo
 */

#include "events_sender.hpp"
#include "logger.hpp"
#include "f_engine.hpp"

boost::shared_ptr<if_system_t> events_sender_t::create(f_engine_t *engine)
{
    boost::shared_ptr<events_sender_t> ret(new events_sender_t(engine));
    logger::log(DEBUG, "[Events sender] Events sender system created.");
    return ret;
}

void events_sender_t::start()
{
    client_.connect("events_channel");

    engine_->report_started();
}

void events_sender_t::send(const event_t & event)
{
    std::string serialized = event.serialize();
    client_.send(serialized.c_str(), serialized.length());
    logger::log(DEBUG) << "Event was sent: " << event.serialize();
}

